﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass()]
public class SortUtilitiesTest
{
    public static bool AreArraysEqual(int[] arr1, int[] arr2)
    {
        if (arr1.Length != arr2.Length)
        {
            return false;
        }
        for (int i = 0; i < arr1.Length; i++)
        {
            if (arr1[i] != arr2[i])
            {
                return false;
            }
        }
        return true;
    }

    [TestMethod()]
    public void RegularInput()
    {
        int[] array = { 1, 3, 2, 4, 5 };
        SortUtilities.InsertionSort(array);
        int[] expected = { 1, 2, 3, 4, 5 };
        Assert.IsTrue(AreArraysEqual(array, expected));
    }

    [TestMethod()]
    public void EmptyArray()
    {
        int[] array = { };
        SortUtilities.InsertionSort(array);
        int[] expected = { };
        Assert.IsTrue(AreArraysEqual(array, expected));
    }

    [TestMethod()]
    public void SingleValue()
    {
        int[] array = { 9999 };
        SortUtilities.InsertionSort(array);
        int[] expected = { 9999 };
        Assert.IsTrue(AreArraysEqual(array, expected));
    }

    [TestMethod()]
    public void InverOrderedInput()
    {
        int[] array = { 5, 4, 3, 2, 1 };
        SortUtilities.InsertionSort(array);
        int[] expected = { 1, 2, 3, 4, 5 };
        Assert.IsTrue(AreArraysEqual(array, expected));
    }

    [TestMethod()]
    public void NegativeNumbers()
    {
        int[] array = { -5, 4, 3, -2, 1 };
        SortUtilities.InsertionSort(array);
        int[] expected = { -5, -2, 1, 3, 4 };
        Assert.IsTrue(AreArraysEqual(array, expected));
    }

    [TestMethod()]
    public void OnlyZeros()
    {
        int[] array = { 0, 0, 0, 0, 0, 0, 0, 0 };
        SortUtilities.InsertionSort(array);
        int[] expected = { 0, 0, 0, 0, 0, 0, 0, 0 };
        Assert.IsTrue(AreArraysEqual(array, expected));
    }

    [TestMethod()]
    public void BorderIntValues()
    {
        int[] array = { int.MaxValue, int.MinValue, int.MinValue, int.MaxValue };
        SortUtilities.InsertionSort(array);
        int[] expected = { int.MinValue, int.MinValue, int.MaxValue, int.MaxValue };
        Assert.IsTrue(AreArraysEqual(array, expected));
    }
}


